import {
  Loading,
  LoadingController,
  ToastController,
  Toast,
  Tabs,
  NavController
} from 'ionic-angular';

export abstract class BaseUI {
  public navCtrl: NavController;
  constructor() {}

  protected showLoading(
    loadingCtrl: LoadingController,
    message: string
  ): Loading {
    let loader = loadingCtrl.create({
      content: message,
      dismissOnPageChange: true,
      duration: 1000
    });
    loader.present();
    return loader;
  }

  protected showToast(toastCtrl: ToastController, message: string): Toast {
    let toast = toastCtrl.create({
      message: message,
      duration: 3000,
      position: 'bottom'
    });
    toast.present();
    return toast;
  }

  selectTab(index: number) {
    var tabs: Tabs = this.navCtrl.parent;
    tabs.select(index);
  }
}
